export interface FileValueItem {
  name: string;
  extname: string;
  url: string;
}

/**
 * uniapp file组件数据回显结构
 * @export
 * @param {string} val
 * @return {*}  {({} | { name: string; extname: string; url: string })}
 */
export function uniFileComValueEcho(val: string): FileValueItem {
  if (!val) {
    throw '请传入字符串';
  }
  val = val.split('?')[0];
  let valArr = val.split('/');
  let name = valArr[valArr.length - 1];
  return {
    name,
    extname: name.split('.')[1],
    url: val,
  };
}
